Using Connection Failover with the .NET Client

The .NET Client can help you make sure that your critical data is available even if the primary database server is unavailable:

Specifying Primary and Alternate Servers

Connection failover allows an application to connect to an alternate, or backup, database server if the primary database is unavailable, for example, because of a hardware failure or traffic overload.

You can customize the .NET data provider for connection failover by configuring a list of alternate database servers that are tried if the primary server is not accepting connections. Connection attempts continue until a connection is successfully established or until all of the alternate database servers have been tried the specified number of times.

The following C# code fragment includes a connection string that configures the .NET Client to use connection failover:

SequeLinkConnection Conn = new SequeLinkConnection(); 
Conn = new SequeLinkConnection("Host=server1;port=19996;ServerDataSource=
SDSN1:User ID=test;Password=secret;Alternate Servers=(Host=server2:Port=
19996:ServerDataSource=SDSN2,Host=server3:Port=19996:ServerDataSource=
SDSN3);Connection Timeout=60" 

Specifically, this connection string configures the .NET Client to use two alternate servers as connection failover servers.

Using Connection Retry

Connection retry defines the number of times that the data provider attempts to connect to the primary, and, if configured, alternate database servers after the first unsuccessful connection attempt. Connection retry can be an important strategy for system recovery. For example, suppose you have a power failure scenario in which both the client and the server fail. When the power is restored and all computers are restarted, the client may be ready to attempt a connection before the server has completed its startup routines. If connection retry is enabled, the client application can continue to retry the connection until a connection is successfully accepted by the server.

Connection retry can be used in environments that only have one server or can be used as a complementary feature in connection failover in environments with multiple servers.

The following C# code fragment includes a connection string that configures the .NET Client to use connection failover in conjunction with connection retry and connection retry delay:

SequeLinkConnection Conn = new SequeLinkConnection(); 
Conn = new SequeLinkConnection("Host=server1;port=19996;ServerDataSource=
SDSN1:User ID=test;Password=secret;Alternate Servers=(Host=server2:Port=
19996:ServerDataSource=SDSN2,Host=server3:Port=19996:ServerDataSource=
SDSN3);Connection Retry Count=4;Connection Retry Delay=5;Connection Timeout=
60" 

Specifically, this connection string configures the .NET Client to use two alternate servers as connection failover servers, to attempt to connect four additional times if the initial attempt fails, and to wait five seconds between attempts. Each connection attempt lasts for 60 seconds.

Using Client Load Balancing

Client load balancing helps distribute new connections in your environment so that no one server is overwhelmed with connection requests. When client load balancing is enabled, the order in which primary and alternate database servers are tried is random.

When Connection Retry is also enabled, the .NET Client tries to connect to the primary SequeLink server and alternate SequeLink servers in a random order until a successful connection is established. If the connection attempt fails, the .NET Client again randomly selects from the list of servers until all SequeLink servers in the list have been tried or a connection is successfully established.

The following C# code fragment includes a connection string that configures the .NET Client to use connection failover in conjunction with all of its optional features-load balancing, connection retry, and connection retry delay:

SequeLinkConnection Conn = new SequeLinkConnection(); 
Conn = new SequeLinkConnection("Host=server1;port=19996;ServerDataSource=
SDSN1:User ID=test;Password=secret;Alternate Servers=(Host=server2:Port=
19996:ServerDataSource=SDSN2,Host=server3:Port=19996:ServerDataSource=
SDSN3);Connection Retry Count=4;Connection Retry Delay=5;Load Balancing=true; 
Connection Timeout=60" 

Specifically, this connection string configures the .NET Client to use two alternate servers as connection failover servers, to attempt to connect four additional times if the initial attempt fails, to wait five seconds between attempts, and to try the primary and alternate servers in a random order. Each connection attempt lasts for 60 seconds.

Connection Failover Properties

Table 11-1 summarizes the connection string options that control how connection failover works with the .NET Client. Refer to the SequeLink Developer's Reference for details about configuring each property.

Table 11-1. Summary: Connection Failover Connection String Options for the .NET Client 
Connection String Option
Characteristic
Alternate Servers
List of alternate database servers. An IP address or server name and a port number are required for each server. The Server Data Source connection string option is optional.
Connection Retry Count
Number of times the data provider retries the primary database server, and if specified, alternate servers until a successful connection is established. The initial default is 0.
Connection Retry Delay
Wait interval, in seconds, between connection retry attempts when the ConnectionRetryCount property is set to a positive integer. The initial default is 3.
Load Balancing
Sets whether the data provider will use client load balancing in its attempts to connect to the list of database servers (primary and alternate). If client load balancing is enabled, the data provider uses a random pattern instead of a sequential pattern in its attempts to connect. The initial default is false (client load balancing is not used).

Refer to the SequeLink Developer's Reference for overviews of connection failover and client load balancing.